<?php
//村信息服务

namespace App\Services;

use App\Repositories\VillagesRepository;

class VillageService
{

    /**
     * 获取列表
     * @param $query
     * @param $offset
     * @param $limit
     * @param $orderType
     * @return array|mixed
     */
    public static function getList($query = [], $offset = 0, $limit = 20, $orderType = 0)
    {
        //获取证书关联信息
        $repo = new VillagesRepository();
        $repo->buildQuery($query);

        return $repo
            ->getList($offset, $limit, $orderType)
            ->toarray();
    }

    /**
     * 获取单条
     * @param $query
     * @return array
     */
    public static function getRow($query = [])
    {
        //获取证书关联信息
        $repo = new VillagesRepository();
        $repo->buildQuery($query);

        $res = $repo->getRow();

        return $res ? $res->toArray() : [];
    }

    /**
     * 获取总数
     * @param $query
     * @return array
     */
    public static function getTotal($query = [])
    {
        //获取证书关联信息
        $repo = new VillagesRepository();
        $repo->buildQuery($query);

        return $repo->getTotal();
    }

}
